package org.chnxi.study.design.single;

import java.lang.reflect.Constructor;

public class EnumSingleTest {

    public static void main(String[] args) throws Exception{
        new Thread(()->{
            EnumSingle instance = EnumSingle.INSTANCE;
            System.out.println(Thread.currentThread().getName()+";instance.hashcode="+instance.hashCode());
            instance.doSomeThring();
        } , "T-1").start();

        new Thread(()->{
            try{
                Constructor<EnumSingle> declaredConstructor = EnumSingle.class.getDeclaredConstructor(null);
                declaredConstructor.setAccessible(true);
                EnumSingle enumSingle = declaredConstructor.newInstance();
            }catch (Exception e){
                System.out.println(Thread.currentThread().getName()+"发生异常："+e.getMessage());
                e.printStackTrace();
            }
        } , "T-2").start();

        new Thread(()->{
            try{
                Constructor<EnumSingle> declaredConstructor1 = EnumSingle.class.getDeclaredConstructor(String.class, int.class);
                declaredConstructor1.setAccessible(true);
                EnumSingle enumSingle1 = declaredConstructor1.newInstance("", 0);
            }catch (Exception e){
                System.out.println(Thread.currentThread().getName()+"发生异常："+e.getMessage());
                e.printStackTrace();
            }
        } , "T-3").start();

    }

}
